<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="model.*"%>
<%@ page import="dao.*"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
	String user = (String)session.getAttribute("user");
	if(user!=null && user.equals("1")){
		
	}else {
		response.sendRedirect("Login.jsp");
	}
%>
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
	List<Route> routes = new ArrayList<Route>();
	routes = RouteDao.getRoutes();
	for (Route item : routes) {
		System.out.println(item.getRname());
	}
	request.setAttribute("routes", routes);
%>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8" />
<title>管理旅游路线</title>


<jsp:include page="Header.jsp" flush="true"></jsp:include>


<!-- Latest Products -->
<div id="旅游路线">

	<div class="content-lg container">
		<div class="row margin-b-40">
			<div class="col-sm-6">
				<h2>管理旅游路线</h2>
				<br>

			</div>
			<div class="col-sm-6">
				<h3>
					<br>
					<a class="btn btn-default "
						href="<%=request.getContextPath()%>/admin/AddRoute.jsp">添加路线</a>
				</h3>
			</div>
		</div>
		<!--// end row -->

		<div class="row">

			<c:forEach var="route" items="${routes}" varStatus="status">

				<div class="row margin-b-10">
					<div class="col-sm-6">
						<h3>路线名字:${route.rcname }</h3>
					</div>
					<div class="col-sm-6">
						<h3>
							操作: <a
								href="javascript:if(confirm('确定要修改吗?'))
								location='<%=request.getContextPath()%>/admin/UpdateRoute.jsp
								?rname=${route.rname }&handle=updateRoute'">
								修改 </a> &nbsp;&nbsp; <a
								href="javascript:if(confirm('确定要删除吗?'))
								location='<%=request.getContextPath()%>/RouteServlet
								?rname=${route.rname }&handle=delRoute'">
								删除 </a> &nbsp;&nbsp; <a
								href="javascript:if(confirm('确定要添加吗?'))
								location='<%=request.getContextPath()%>/admin/AdminAddVroutList.jsp
								?rname=${route.rname }&handle=AddVroute'">
								添加景点 </a> <a
								href="javascript:if(confirm('确定要添加吗?'))
								location='<%=request.getContextPath()%>/admin/AdminAddHroutList.jsp
								?rname=${route.rname }&handle=AddHroute'">
								添加酒店 </a>
						</h3>
						<p></p>
					</div>

				</div>
				<div class="row">
						<div class="col-sm-2"><h5>&nbsp;路线金额&nbsp;:&nbsp;${route.money }</h5></div>
						<div class="col-sm-2"><h5>&nbsp;路线时长&nbsp;:&nbsp;${route.days }</h5></div>
						<div class="col-sm-8"><h5>&nbsp;路线信息&nbsp;:&nbsp;${route.info }</h5></div>
				</div>



				<table class="table table-bordered mtable2" width="100%"
					cellspacing="0">
					<thead>
						<tr>
							<th>序号</th>
							<th>名称</th>
							<th>图片</th>
							<th>信息</th>
							<th>价格</th>
							<th>操作</th>
						</tr>
					</thead>
				
					<tbody>
						<c:forEach var="vroute" items="${route.getVroutes()}"
							varStatus="status">
							<tr>
								<td>${status.index +1}</td>
								<td>${vroute.getView().vcname }</td>
								<td><a target="_blank"
									href="<%=request.getContextPath()%>/${view.location }">查看图片</a></td>
								<td>${vroute.getView().info }</td>
								<td>${vroute.getView().price }</td>
								<td><a
									href="javascript:if(confirm('确定要删除吗?'))location='<%=request.getContextPath()%>/VrouteServlet?vname=${vroute.id.getVName() }&rname=${vroute.id.getRName() }&handle=delVroute'">删除</a>
								</td>

							</tr>

						</c:forEach>
							<thead>
					<tr>
						<th>序号</th>
						<th>名称</th>
						<th>图片</th>
						<th>信息</th>
						<th>价格</th>
						<th>操作</th>
					</tr>
				</thead>
							<c:forEach var="hroute" items="${route.getHroutes()}"
							varStatus="status">
							<tr>
								<td>${status.index +1}</td>
								<td>${hroute.getHotel().name }</td>
								<td><a target="_blank"
									href="<%=request.getContextPath()%>/${hroute.getHotel().location }">查看图片</a></td>
								<td>${hroute.getHotel().info }</td>
								<td>${hroute.getHotel().price }</td>
								<td><a
									href="javascript:if(confirm('确定要删除吗?'))location='<%=request.getContextPath()%>/HrouteServlet?hemail=${hroute.id.getHEmail() }&rname=${hroute.id.getRName() }&handle=delHroute'">删除</a>
								</td>

							</tr>

						</c:forEach>
					</tbody>
				</table>
				<br>
				<br>
			</c:forEach>


		</div>
		<!--// end row -->
	</div>
</div>
</div>
<!-- End Latest Products -->

<jsp:include page="Footer.jsp" flush="true"></jsp:include>
<%
	String flag = "";
	String scerror = "";
	flag = (String) request.getAttribute("flag");
	System.out.println("jspflag" + flag);
	if (flag != null) {
		if (flag.equals("1")) {
			scerror = "删除成功。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("0")) {
			scerror = "删除失败。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("3")) {
			scerror = "添加成功。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("2")) {
			scerror = "添加失败。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("5")) {
			scerror = "修改成功。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("4")) {
			scerror = "修改失败。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}

	}
	System.out.println(scerror);
%>
<!-- Back To Top -->
<a href="javascript:void(0);" class="js-back-to-top back-to-top">Top</a>

<!-- JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- CORE PLUGINS -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<script src="vendor/jquery-migrate.min.js" type="text/javascript"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"
	type="text/javascript"></script>
</body>
<!-- END BODY -->
</html>